Skip to content

fix(mem): fix various issues in mem#35

Merged
krokoko merged 2 commits intomainfrom
mem0fix
Apr 16, 2026
Merged

fix(mem): fix various issues in mem#35
krokoko merged 2 commits intomainfrom
mem0fix

Conversation

@krokoko
Copy link
Copy Markdown
Contributor

@krokoko krokoko commented Apr 16, 2026

  • Fix critical design flaw in memory integrity hashing: The original implementation hashed raw content on write but verified against sanitized content on read — hashes would never
    match for records containing sanitizable content. Additionally, AgentCore's extraction pipeline transforms content via LLM summarization/consolidation, meaning extracted records will
    always differ from write-time content. Changed integrity verification from fail-closed (discard records) to audit-only (log at WARN, keep records). Read-path sanitization
    (sanitizeExternalContent) is the real defense against content tampering.
    • Harden memory pipeline with sanitization, provenance, and cross-language parity: Extract shared sanitization.py module (Python mirror of TS sanitizeExternalContent), add
      MemorySourceType provenance tagging on all memory writes, sanitize taskDescription before prompt injection in context hydration, add severity-aware error handling (programming errors
      re-thrown/logged at ERROR, infra failures fail-open at WARN), and add cross-language SHA-256 test fixtures.
    • Improve test coverage: Add tests for semantic + episodic hash mismatch paths, v3-missing-hash detection, backward compatibility (v2 records), hash-matches-sanitized-content
      correctness, negative-log assertions, cross-language hash parity (shared JSON fixture consumed by both Jest and pytest), and context hydration sanitization.

Area

  • cdk — infrastructure, handlers, constructs
  • agent — Python runtime / Docker image
  • clibgagent client
  • docs — guides or design sources (docs/guides/, docs/design/)
  • tooling — root mise.toml, scripts, CI workflows

Tip: AGENTS.md lists where to edit and which tests to extend.

Related

Changes

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

@leandrodamascena
Copy link
Copy Markdown
Contributor

I did some analysis with the automated review agents and I think this closes the loop on the hash concern you raised @krokoko. Hashing sanitized content fix this and also the shared fixture for cross-language parity is something I wanted to add but didn't get to.

I'm pulling it down to test now in my local.

@krokoko krokoko marked this pull request as ready for review April 16, 2026 20:24
@krokoko krokoko requested a review from a team as a code owner April 16, 2026 20:24
@krokoko krokoko merged commit 9019784 into main Apr 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants